package dse.messages.multiversion;

import dse.Experiment;
import dse.ExperimentRecorder;
import dse.messages.Message;
import dse.messages.MessageHandler;
import dse.messages.MessageSender;
import dse.messages.MessageType;
import dse.messages.singleversion.LockProcessor;

public class UpdateLockResponseMessageHandler extends MessageSender implements
		MessageHandler {
	private LockProcessor lp;
	
	public UpdateLockResponseMessageHandler(Experiment experiment, LockProcessor lp){
		super(experiment);
		this.lp = lp;
	}
	
	@Override
	public boolean acceptMessage(Message message) {
		// TODO Auto-generated method stub
		return true;
	}

	@Override
	public void messageInterupted(ExperimentRecorder recorder, Message message,
			double time) {
		// TODO Auto-generated method stub

	}

	@Override
	public void messageReceived(ExperimentRecorder recorder, Message message,
			double time) {
		// TODO Auto-generated method stub
		if (message.messageType() != MessageType.UpdateLockResponse) {
			recorder.warn(
					"UpdateLockResponseMessageHandler recieved " + 
					message.messageType() + " message."
					);
			return;
		}
		lp.lockProcess(true, message.from(), recorder, time);
	}
}
